const element = document.getElementById("document");
const rect = element.getBoundingClientRect();
const top = rect.top;
const left = rect.left;
const width = rect.width;
const height = rect.height;

//获取元素上方和左右的位置
const offTop = element.offsetTop;
const offLeft = element.offsetLeft;

//获取鼠标x.y坐标
element.addEventListener("mousemove", function (e) {
    console.log("鼠标的x坐标", e.pageX);
    console.log("鼠标的y坐标", e.pageY);
})


//鼠标在视口的x/y坐标
element.addEventListener("mousemove", function (e) {
    console.log("鼠标在视口的x坐标", e.clientX);
    console.log("鼠标在视口的y坐标", e.clientY);
})